#include <iostream>
using std::cout;
using std::endl;

class A{
public:
    ~A(){
        cout << "~A()" << endl;
    }
};

class B{
public:
    ~B(){
        cout << "~B()" << endl;
    }
};

class C{
public:
    ~C(){
        cout << "~C()" << endl;
    }
};

class D{
public:
    ~D(){
        cout << "~D()" << endl;
    }
};

//1.pa是手动销毁的
//2.b是函数执行完后清理栈空间时被销毁
//3.c和d是程序结束时清理全局静态区时被销毁
//c和d顺序遵循先创建后销毁，所以先调用d的析构，
//再调用c的析构
C c;
int main(void){
    A * pa = new A;
    B b;
    static D d;
    delete pa;
    return 0;
}


